//
//  TopView.m
//  atlas
//
//  Created by 你好 on 17/1/16.
//  Copyright © 2017年 xyxNav. All rights reserved.
//

#import "TopView.h"
#import "UserManager.h"
#import "PhotoAlbum.h"

@implementation TopView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/


-(instancetype)initWithFrame:(CGRect)frame
{
    self=[super initWithFrame:frame];
    if (self)
    {

    }
    return self;
}

-(void)configUI
{
    
    self.contentMode=UIViewContentModeScaleAspectFill;
    self.clipsToBounds=YES;
    self.userInteractionEnabled=YES;

    self.coverBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    self.coverBtn.frame=self.bounds;
    self.coverBtn.backgroundColor=[UIColor colorWithWhite:1 alpha:0.5];
    [self addSubview:self.coverBtn];
    
}


-(void)configData:(Recommend *)recommend
{
    self.coverBtn.alpha=0.5f;
    NSString *bgImageUrl=[NSString stringWithFormat:@"%@/%@?token=%@",GETIMAGE_URL,recommend.imageUrl,[UserManager shareInstance].userToken];
    [self sd_setImageWithURL:[NSURL URLWithString:bgImageUrl] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        [UIView animateWithDuration:1.5 animations:^{
            self.coverBtn.alpha=0.02f;
        }completion:^(BOOL finished) {
        }];
    }];
    
}


@end
